home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / oath.lha / oath / test / ms2b.cc < prev    next >
C/C++ Source or Header  |  1991-08-29  |  2KB  |  54 lines

  1. #include "oath/minString.h"
  2.  
  3. #include <fstream.h>
  4.  
  5. /////////////////////////////////////////////////////////////////////////////
  6. // Test of minStrings
  7.  
  8. main()
  9.    {// Create some Characters //////////
  10.     characterA R = characterA::make('r');
  11.     characterA S = characterA::make('s');
  12.     characterA T = characterA::make('t');
  13.     characterA L = characterA::make('l');
  14.     characterA N = characterA::make('n');
  15.     characterA E = characterA::make('e');
  16.     characterA A = characterA::make('a');
  17.  
  18.     // Retrieve the Strings //////////
  19.     ifstream File ("ms2.obj");
  20.  
  21.     stringA Star = stringA::isa(objA::import(File));
  22.     stringA Sstare = stringA::isa(objA::import(File));
  23.  
  24.     cout << Star.am() << "\t(" << Star.hash() << ")" << endl;
  25.     cout << Sstare.am() << "\t(" << Sstare.hash() << ")" << endl;
  26.  
  27.     // Test Strings //////////
  28.     stringPosA Pstare = Sstare.makePos();
  29.     cout << "First char is " << *Pstare << endl;
  30.     Pstare.findMatch("tar");
  31.     cout << "Char after tar is " << *Pstare << endl;
  32.  
  33.     Pstare.reset();
  34.     if(Pstare.canMatch("sta"))
  35.         cout << "It can match 'sta', if you wish." << endl;
  36.  
  37.     if(!!Pstare.match(""))
  38.         cout << "It just matched nothing successfully." << endl;
  39.  
  40.     ///
  41.  
  42.     char * Buffer = new char [50];
  43.     for(int I = 0; I < 5; I++)
  44.        {for(int J = 0; J < 10; J++)
  45.             Buffer[I*10 + J] = J;
  46.        }
  47.     stringA Sbuffer = minStringA::make(Buffer, Buffer+42);
  48.     cout << "Sbuffer is " << Sbuffer.count() << " char's long." << endl;
  49.     char * Buffer2 = new char [40];
  50.     Sbuffer.charStarX(Buffer2, 40);
  51.     if(!memcmp(Buffer, Buffer2, 40))
  52.         cout << "Success!  The buffers are the same!" << endl;
  53.   
  54.    }